<?php

/*
 * This file is part of the symfony package.
 * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
 * 
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * sfWidgetFormInput represents an HTML input tag.
 *
 * @package    symfony
 * @subpackage widget
 * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
 * @version    SVN: $Id: sfWidgetFormInput.class.php 9046 2008-05-19 08:13:51Z FabianLange $
 */
class inputMat2ImageTag extends sfWidgetFormInput
{
  /**
   * @param array $options     An array of options
   * @param array $attributes  An array of default HTML attributes
   *
   * @see sfWidgetFormInput
   */
  protected function configure($options = array(), $attributes = array())
  {
    parent::configure($options, $attributes);

    $this->setOption('type', 'file');
    $this->setOption('needs_multipart', true);
  }
  
public function render($name, $value = 'not', $attributes = array(), $errors = array())
  {
  	
  	if($attributes['mat_id']>0)
  	{
  	   $str= link_to_remote(__('Добавить материал'), array(
			    'update' => 'add_material_form',
                'script'=>'true',
			    'url'    => 'material/show_material_form?type=5&from_id='.$attributes['mat_id'],
			    'loading'  => "Element.show('add_material_indicator');Element.hide('materials');",
			    'complete' => "Element.hide('add_material_indicator');bkLib.onDomLoaded(function() { nicEditors.allTextAreas() });",
			    ));
      $str.=get_component('zdRelation','show_gallery',array('mat_id'=>$attributes['mat_id']));
  	}
  	else {
  		$str = '<center><font color="red">'.__('Материал не создан').'</font></center>';
  	}
  	
    return $str;
  }
}